//
//  MainViewController.m
//  UI08_5_协议从前页向后页传值
//
//  Created by Scott on 15/5/16.
//  Copyright (c) 2015年 www.lanou3g.com 蓝欧3G. All rights reserved.
//

#import "MainViewController.h"
#import "SecondViewController.h"

@interface MainViewController ()

@property (nonatomic, retain) UIButton *button;
@property (nonatomic, retain) UITextField *textField;

@end

@implementation MainViewController

- (void)dealloc
{
    [_button release];
    [_textField release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 80, 280, 40)];
    self.textField.borderStyle = 3;
    [self.view addSubview:self.textField];
    [_textField release];
    
    
    
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    self.button.frame = CGRectMake(20, 200, 100, 40);
    [self.button setTitle:@"OK" forState:UIControlStateNormal];
    [self.view addSubview:self.button];
    [self.button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    
    
}

- (void)button:(UIButton *)button
{
    
    SecondViewController *second = [[SecondViewController alloc] init];
    
    self.delegate = (id)second;

    [self.delegate passValue:self.textField.text];
    
    [self.navigationController pushViewController:second animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
